package com.util;

import com.javabean.Student;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class CommentTest {
    ClassPathXmlApplicationContext  applicationContext;
    @Before
    public void before(){
       applicationContext=new ClassPathXmlApplicationContext("spring-comment.xml");
    }

    @After
    public void after(){
        applicationContext.close();
    }
    @Test
    public void studentTest(){
        Student s1 = applicationContext.getBean(Student.class);
        System.out.println(s1);
        Object s2 = applicationContext.getBean("student");
        System.out.println(s2);
    }

    @Test
    public void TeacherTest(){

        Object t1 = applicationContext.getBean("t1");
        System.out.println(t1);
        Object t2 = applicationContext.getBean("teacher");
        System.out.println(t2);
    }
    @Test
    public void studentPrototype(){

        Object s1 = applicationContext.getBean("student");
        Object s2 = applicationContext.getBean("student");
        System.out.println(s1==s2);
    }


    @Test
    public void Teacher2(){

        Object t1 = applicationContext.getBean("t1");
        System.out.println(t1);
        Object t2 = applicationContext.getBean("t1");
        System.out.println(t2);
    }

}
